package com.android.commcount.dialog;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.fragment.app.FragmentManager;

import com.android.baselibrary.dialog.BaseDialogFragment;
import com.android.baselibrary.util.GlideUtil;
import com.android.baselibrary.util.Util;
import com.android.baselibrary.view.Comm_HeadView;
import com.android.commcount.R;
import com.android.commcount.R2;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;

import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 数东西示例
 */

public class Count_Model_DialogFragment extends BaseDialogFragment {

    @BindView(R2.id.iv_img)
    ImageView iv_img;

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_count_model;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        //  375 * 678
        int margin = Util.dip2px(mContext, 3);

        int width = getResources().getDisplayMetrics().widthPixels - Util.dip2px(mContext, 50) - margin * 2;
        int height = (int) (width * 678d / 375d);


        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) iv_img.getLayoutParams();
        layoutParams.width = width;
        layoutParams.height = height;
        layoutParams.setMargins(margin, margin, margin, 0);
        iv_img.setLayoutParams(layoutParams);

        String path = "file:///android_asset/anim1.gif";
        Glide.with(mContext).asGif().load(path).into(iv_img);
    }

    @Override
    protected int getShowDirection() {
        return BaseDialogFragment.Direction_FadeIn;
    }

    @Override
    public void setData(Map<String, Object> params) {
        if (params != null) {
        }
    }

    public static BaseDialogFragment showDialog(FragmentManager fragmentManager, Map<String, Object> params) {
        Count_Model_DialogFragment dialogFragment = new Count_Model_DialogFragment();
        dialogFragment.setData(params);
        dialogFragment.show(fragmentManager, "");
        return dialogFragment;
    }


    @OnClick({R2.id.ll_close})
    public void onViewClicked(View view) {
        if (view.getId() == R.id.ll_close) {
            dismissWithAnim();
        }
    }


}
